//继承

//
var util = require('util');
function Base() {
    this.name = 'base';
    this.base = 1991;
    this.sayHello = function() {
        console.log('Hello ' + this.name);
    };
}
Base.prototype.showName = function() {
    console.log(this.name);
};
function Sub() {
    this.name = 'sub';
}
util.inherits(Sub, Base);
var objBase = new Base();
objBase.showName();
objBase.sayHello();
console.log(objBase);


var objSub = new Sub();
console.log('sub继承了showName方法：');
objSub.showName();
//objSub.sayHello(); //开启会挂掉，因为非原型中定义的属性不被继承。ptototype
console.log(objSub);


console.log('Base',Base);
console.log('Sub',Sub);//工具类将属性、方法挂载到了new 之后的实例对象中，而不是Sub本身。
//所以只是个假的继承，没有到编程语言层面上
